﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Diagnostics;
using Telerik.Windows;
using Telerik.Windows.Controls.GridView;
using Telerik.Windows.Controls;
using HeThongThongTin.Library;
using HeThongThongTin.UI.SL.DanhMuc.DM_Table;
using HeThongThongTin.UI.SL.BaoCaoThongKe.DanhMuc;
using Converter;
using System.Resources;
using System.Reflection;


namespace HeThongThongTin.UI.SL.BaoCaoThongKe.DanhMuc.DM_CaNhan
{
    public partial class DM_CaNhanReport_MainWindow : UserControl, Csla.Xaml.ISupportNavigation
    {

        #region ISupportNavigation Members
        List<Control> controls = new List<Control>();
        public bool CreateBookmarkAfterLoadCompleted
        {
            get { return true; }
        }

        public event EventHandler LoadCompleted;

        protected virtual void OnLoadCompleted()
        {
            if (LoadCompleted != null)
                LoadCompleted(this, EventArgs.Empty);
        }

        public void SetParameters(string parameters)
        {
            // no parameters
        }

        public string Title
        {
            get { return "CaNhanReport"; }
        }

        #endregion

        #region Load Methods
        public DM_CaNhanReport_MainWindow()
        {
            LocalizationConverter converter = new LocalizationConverter();
            converter.LocalResourceManager = new ResourceManager("HeThongThongTin.UI.SL.BaoCaoThongKe.DanhMuc.DM_CaNhan.Resources", Assembly.GetExecutingAssembly());
            this.Resources.Add("Localization", converter);
            InitializeComponent();
           
            
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                
                System.Windows.Data.CollectionViewSource dm_Table_ViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_Table_ViewModelSource"];
                DM_Table_ViewModel dm_Table_ViewModel = new DM_Table_ViewModel(1);
                dm_Table_ViewSource.Source = new List<object> { dm_Table_ViewModel };
                
            }
        }       
        #endregion

        private void ComboBox_KeyUp(object sender, KeyEventArgs e)
        {
            ControlBehavior.ComboBoxBehaviors.ComboBox_KeyUp(sender, e, controls);
        }

        private void Control_KeyUp(object sender, KeyEventArgs e)
        {

            ControlBehavior.ControlBehaviors.Control_KeyUp(sender, e, controls);
        }
        private void DatePicker_KeyUp(object sender, KeyEventArgs e)
        {    
            ControlBehavior.DatePickerBehaviors.DatePicker_KeyUp(sender, e, controls);            
        }

        private void PrintItemButton_Click(object sender, RoutedEventArgs e)
        {
            System.Collections.ObjectModel.ObservableCollection<object> list = this.DM_CaNhanReport_GridView.SelectedItems;

            List<string> selectItems = new List<string>();
            foreach (DM_Table_FieldChild item in list)
            {
                selectItems.Add(item.Ten);
            }

            DM_CaNhanReport report = new DM_CaNhanReport(selectItems);
            report.Show();
        } 

    }
}
